package tests;//package com.mika.music.tests;


import org.openqa.selenium.By;
import utils.AutoTestUtils;

import java.io.IOException;

public class LoginPage extends AutoTestUtils {
    public static String url = "http://114.55.226.213:8080/login.html";

    public LoginPage() {
        super(url);
    }

    public void loginSuc() {
        // 先清空输入框
        driver.findElement(By.xpath("//*[@id=\"user\"]")).clear();
        driver.findElement(By.xpath("//*[@id=\"password\"]")).clear();

        // 输入正确的账号密码
        driver.findElement(By.xpath("//*[@id=\"user\"]")).sendKeys("mika");
        driver.findElement(By.xpath("//*[@id=\"password\"]")).sendKeys("123");
        driver.findElement(By.xpath("//*[@id=\"submit\"]")).click();
    }

    public void loginFail() throws IOException, InterruptedException {
        // 先清空输入框
        driver.findElement(By.xpath("//*[@id=\"user\"]")).clear();
        driver.findElement(By.xpath("//*[@id=\"password\"]")).clear();
        // 账户密码都是空的测试
        driver.findElement(By.xpath("//*[@id=\"submit\"]")).click();
        AutoTestUtils.getScreenshot("loginFail");


        // 输入的错误账号密码
        driver.findElement(By.xpath("//*[@id=\"user\"]")).sendKeys("mika1111111");
        driver.findElement(By.xpath("//*[@id=\"password\"]")).sendKeys("123");
        driver.findElement(By.xpath("//*[@id=\"submit\"]")).click();

        // 截图看看到底登录进去没
        AutoTestUtils.getScreenshot("loginFail");
        
    }


}
